# php develop env - A base ubuntu 18
#
# you can install any version of php , also can always keep pace with the lastest app updates.
# origin ubuntu image (deb)binary install all app
# php7.x runtime env supported
FROM ubuntu:18.04

LABEL maintainer="Markway<ljwnet163@163.com>" version="php73.001" license="MIT"
# 引入系统变量
ARG timezone

ENV APP_ENV=prod \
    # 时区
    TIMEZONE=${timezone:-"Asia/Shanghai"} \
    DEBIAN_FRONTEND=noninteractive
WORKDIR /tmp/deb
RUN set -ex && \
    apt update && \
    # https前置
    apt install -y apt-utils ca-certificates && \
    # 换阿里的源镜像(可选)
    cp /etc/apt/sources.list /etc/apt/sources.list.bak && \
    sed -i 's/http\:\/\/archive\.ubuntu\.com/https:\/\/mirrors\.aliyun\.com/g' /etc/apt/sources.list && \
    # 更新源列表 (必须de)
    apt update && \
    # 更新应用 (可选)
    #apt upgrade -y && \
    # apt管理工具 add-apt-repository[apt-utils]
    apt install -y apt-transport-https tzdata && \
    ln -fs /usr/share/zoneinfo/PRC /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata && \
    # app编译安装相关
    apt install -y libtool gcc software-properties-common && \
    # repo add
    add-apt-repository ppa:ondrej/php && \
    # add-apt-repository ppa:chris-lea/redis-server && \
    apt update && \
    # php
    apt install -y php7.3 php7.3-fpm php7.3-dev php7.3-curl php7.3-gd php7.3-mysql  php7.3-mbstring php7.3-xml php7.3-bcmath php7.3-opcache php7.3-zip && \
    apt install -y php-pear composer && \
    # pecl install swoole
    # socket改成端口
    LISTEN_LINE_INFO=`more /etc/php/7.3/fpm/pool.d/www.conf | grep 'listen =' -n` && \
    sed -i ${LISTEN_LINE_INFO%%\:*}'i listen = 9073' /etc/php/7.3/fpm/pool.d/www.conf && \
    sed -i 's/^listen = \(.*\).sock/;listen=\1.sock/g' /etc/php/7.3/fpm/pool.d/www.conf && \
    service php7.3-fpm restart && \
    service php7.3-fpm status

EXPOSE 9073 
#ENTRYPOINT ["service","enable","php7.3-fpm"]


